﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using YArchitech.LIB;
using QuickModel.Forms;

namespace QuickModel.RoomTransModel
{
	internal class RoomResponseHanlder : IResponseHanlder
	{
		public void AddEndTime(DateTime inputDataTime)
		{
			this.m_endTime = inputDataTime;
		}

		public void AddOneResponse(RevitModelRebuildResponse inputResponse)
		{
			this.m_lstResponse.Add(inputResponse);
		}

		public void AddStartTime(DateTime inputDataTime)
		{
			this.m_startTime = inputDataTime;
		}

		public void HanlderResponse()
		{
			try
			{
				int num = this.m_lstResponse.Count((RevitModelRebuildResponse item) => item.IfSucess && (item.ThisBuildData as RoomBuildData).HasCreatedRoom);
				int num2 = this.m_lstResponse.Count((RevitModelRebuildResponse item) => item.IfSucess);
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.Append("成功生成房间");
				stringBuilder.Append(num.ToString());
				stringBuilder.Append("个\n");
				stringBuilder.Append("成功转换房间标记");
				stringBuilder.Append(num2.ToString());
				stringBuilder.Append("个\n");
				stringBuilder.Append("时间：");
				stringBuilder.Append(((int)(this.m_endTime - this.m_startTime).TotalSeconds).ToString());
				stringBuilder.Append("秒");
				Process currentProcess = Process.GetCurrentProcess();
				IntPtr mainWindowHandle = currentProcess.MainWindowHandle;
				YJKWindowHandle owner = new YJKWindowHandle(mainWindowHandle);
				TransResultForm transResultForm = new TransResultForm(stringBuilder.ToString());
				transResultForm.ShowDialog(owner);
			}
			catch (Exception ex)
			{
			}
		}

		private DateTime m_startTime = default(DateTime);

		private DateTime m_endTime = default(DateTime);

		private List<RevitModelRebuildResponse> m_lstResponse = new List<RevitModelRebuildResponse>();
	}
}
